#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
void rotate(int* nums, int numsSize, int k)
{
    int count = 0;
    int start = 0, cur = 0, next = 0;
    k %= numsSize;
    while (count != numsSize)
    {
        cur = start;
        int t1 = nums[start];
        int t2 = 0;
        do
        {
            next = (cur + k) % numsSize;
            t2 = nums[next];
            nums[next] = t1;
            cur = next;
            t1 = t2;
            count++;
        } while (cur != start);
        start++;
    }
}
int main()
{
    int len = 0;
    int k = 0;
    int i = 0;
    scanf("%d%d", &len,&k);
    int* arr = (int*)malloc(sizeof(int) * len);
    for (i = 0; i < len; i++)
    {
        scanf("%d", &arr[i]);
    }
    rotate(arr, len, k);
    for (i = 0; i < len; i++)
    {
        printf("%d ", arr[i]);
    }
    return 0;
}